#include<func.h>
int main(void)
{
    //匿名管道 写端一直写 读端关闭了
    int fds[2];
    pipe(fds);
    if(fork())
    {
        //父进程  父进程写
        close(fds[0]);
        //对管道进行读
        printf("sleep is over\n");
        ssize_t sret = write(fds[1],"helloworld\n",12);
        printf("sret = %ld\n",sret);
        close(fds[1]);
        sleep(10);
        return 0;
    }
    else
    {
        sleep(5);
        //读端
        close(fds[1]);
        char buf[4096]={0};
        ssize_t sret = read(fds[0],buf,sizeof(buf));
        printf("sret = %ld buf = %s\n",sret,buf);
        close(fds[0]);//读端后关
        return 0;
    }

    
}